//
//  XMButton.m
//  Second
//
//  Created by Alex on 16/7/15.
//  Copyright © 2016年 蓝鸥科技有限公司西安分公司. All rights reserved.
//

#import "XMButton.h"

@implementation XMButton

- (CGRect)imageRectForContentRect:(CGRect)contentRect {
    
    return CGRectMake(0,15, self.bounds.size.width, self.bounds.size.width);
}

- (CGRect)titleRectForContentRect:(CGRect)contentRect {
    
    return CGRectMake(0,15, self.bounds.size.width, 20);
}

- (void)setTitle:(NSString *)title forState:(UIControlState)state{
    
    [super setTitle:title forState:state];
    self.titleLabel.font = [UIFont systemFontOfSize:12];
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    [self setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
}


- (void)setImage:(UIImage *)image forState:(UIControlState)state {
    
    [super setImage:image forState:state];
}

+ (instancetype)buttonWithTitle:(NSString *)title imageTitle:(NSString *)imageTitle center:(CGPoint)point color:(UIColor *)color{

    CGRect frame = CGRectMake(0, 0, 55, 55);
    XMButton *menu = [[XMButton alloc] initWithFrame:frame];
    menu.center = point;
    menu.backgroundColor = color;
    menu.layer.cornerRadius = 55/2.0;
    [menu setTitle:title forState:UIControlStateNormal];
    [menu setImage:[UIImage imageNamed:imageTitle] forState:UIControlStateNormal];
    return menu;
}


@end
